package edu.lingnan.rili.utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * @Description: 自定义资源映射
 * <p>
 * 设置虚拟路径，访问绝对路径下资源
 * </p>
 * @date: 2019/4/17 18:17
 */


// @ComponentScan
// @Configuration
// public class ConfigurationFactory implements WebMvcConfigurer {
public class ConfigurationFactory{
    // @Autowired
    ConfigurationData configurationData;

    // @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        //设置图片上传的地址
        System.out.println
                ("configurationData测试用application.properties将数据注入到属性上：" + configurationData.getUploadPath());
        registry.addResourceHandler("/**")
                .addResourceLocations("file:" + configurationData.getUploadPath());
        System.out.println("测试映射注解类UploadAddress启动完成");

        //配置swagger-ui.html映射路径
        // registry.addResourceHandler("swagger-ui.html")
        //         .addResourceLocations("classpath:/META-INF/resources/");
        // registry.addResourceHandler("/webjars/**")
        //         .addResourceLocations("classpath:/META-INF/resources/webjars/");
        // System.out.println("测试swagger的映射地址的配置");
    }

}
